﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Demo:发起</title>

    <!-- 引入常用的JS脚本. -->
    <script src="../WF/Scripts/QueryString.js"></script>
    <script src="../WF/Scripts/jquery/jquery.min.js" type="text/javascript"></script>
    <script src="../WF/Scripts/jquery/jquery.cookie.js" type="text/javascript"></script>
    <link href="../WF/Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" />
    <link href="../WF/Scripts/bootstrap/css/font-awesome.css" rel="stylesheet">
    <link href="skin/css/style.css" rel="stylesheet" type="text/css" />
    <link href="skin/css/animate.css" rel="stylesheet" type="text/css" />
    <link href="Style/skin/layui/css/layui.css" rel="stylesheet" />
    <!-- 引入ccbpm 的sdk开发js.  -->
    <script src="../WF/config.js" type="text/javascript"></script>
    <script src="../WF/Dev2Interface.js" type="text/javascript"></script>
    <script src="Style/skin/layui/layui.js"></script>
    <script language="javascript" type="text/javascript">

        //启动函数
        $(function () {


            $("#docs").html("<img src=./Img/loading.gif />&nbsp;正在加载,请稍后......");

            // ccbpmHostDevelopAPI 变量是定义在 /config.js 的服务地址. 访问必须两个参数DoWhat,SID.
            $("#title").html("发起列表-Demo : <lable>文件:Dev2Interface.js 方法:DB_Start</lable>");
            var myNum = 0;
            //调用 /WF/Dev2Interface.js 的 DB_Start() 接口，获得当前人员可以发起的列表.
            var ens = DB_Start();
            var map = {};
            var res = [];
            for (var i = 0; i < ens.length; i++) {
                var name = ens[i].FK_FlowSortText;
                if (!map[name]) {
                    map[name] = {
                        data: name,
                    }
                    res.push(map[name]);
                }
            }
            var listbox = '';
            console.log(res)
            for (var j = 0; j < res.length; j++) {
                var typename = res[j];
                listbox += "<div class='col-lg-4 col-md-4 col-sm-4 col-xs-12'><div class='itemt' data-order='" + myNum + "'><div class='ibox float-e-margins'><div class='ibox-title'><h5>" + typename.data + "</h5><div class='ibox-tools'><a class='collapse-link' data-toggle='collapse'  href='#collapse" + myNum + "'><i class='fa fa-chevron-down' alert='Min' id='Img" + myNum + "' onclick=\"GroupBarClick('" + myNum + "')\"></i></a></div></div><div id='collapse" + myNum + "' class='ibox-contents collapse in'><table class='table table-striped notab'><tbody>";

                for (var i = 0; i < ens.length; i++) {
                    var en = ens[i];
                    if (en.FK_FlowSortText == typename.data) {
                        listbox += "<tr>";
                        listbox += "<td>" + (i + 1) + "</td>"; //序号
                        listbox += "<td><a href=\"javascript:OpenForm('" + en.No + "');\">" + en.Name + "</a></td>";

                        //调用 /WF/Dev2Interface.js 里面的 OpenForm 方法打开表单.
                        listbox += "<td></td>";
                        listbox += "</tr>";
                    }
                }
                listbox += '</tbody></table></div></div></div></div>';
                myNum++;
            }
            $('#lists').html(listbox);
            /*var html = "<table class='table table-bordered table-striped table-hover '>";
            html += "<thead><tr>";
            html += "<th>#</th>";
            //html += "<th>类别编号</th>";
            html += "<th>流程类别</th>";
            html += "<th>流程编号</th>";
            html += "<th>流程名称</th>";
            html += "<th>操作</th>";
            html += "</tr></thead><tbody>";

            for (var i = 0; i < ens.length; i++) {
                var en = ens[i];
                html += "<tr>";
                html += "<td>" + (i + 1) + "</td>"; //序号
                //html += "<td>" + en.FK_FlowSort + "</td>"; //流程类别编号.
                html += "<td>" + en.FK_FlowSortText + "</td>"; //类别名称.
                html += "<td>" + en.No + "</td>"; //流程编号.
                html += "<td>" + en.Name + "</td>"; //流程名称.

                //调用 /WF/Dev2Interface.js 里面的 OpenForm 方法打开表单.
                html += "<td><a href=\"javascript:OpenForm('" + en.No + "');\"  class=\"edit btn btn-success btn-sm\">发起流程</a></td>";
                html += "</tr>";
            }
            html += "</tbody></table>";
            $("#docs").html(html);*/
        });
        function GroupBarClick(groupName) {

            var alt = document.getElementById('Img' + groupName).alert;
            var sta = 'block';
            if (alt == 'Max') {

                sta = 'block';
                alt = 'Min';
                classname = 'fa fa-chevron-down';
                $("#collapse" + groupName).show();

            } else {
                sta = 'none';
                alt = 'Max';
                classname = 'fa  fa-chevron-up';
                $("#collapse" + groupName).hide();
            }

            document.getElementById('Img' + groupName).className = classname;
            document.getElementById('Img' + groupName).alert = alt;
        }
    </script>
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row c" id="lists">
        </div>


    </div>
    <!--body>
        <div class="main-content">
            <div class="card">
                <div id="title" class="card-title"></div>

                <div id="docs"></div>
            </div>
        </div-->
</body>
</html>